/*
*	Developed by Leonardo Chatain and Pedro Dusso, at Universidade Federal do Rio Grande do Sul, Brasil, 2009/1
*	Source available at glpacman.codeplex.com
*/

#include "PerspectiveCamera.h"

PerspectiveCamera::PerspectiveCamera(void)
{
}

PerspectiveCamera::PerspectiveCamera(float posX, float posY, float posZ, float lookAtX, float lookAtY, float lookAtZ) {
	position.setXYZ(posX, posY, posZ);
	lookAt.setXYZ(lookAtX, lookAtY, lookAtZ);
}

PerspectiveCamera::PerspectiveCamera(Point3D pos, Point3D look) {
	this->position = pos;
	this->lookAt = look;
}

PerspectiveCamera::PerspectiveCamera(Point3D pos, Vector3D look) {
	this->position = pos;
	this->setLookAt(look);
}

PerspectiveCamera::PerspectiveCamera(float posX, float posY, float posZ, float lookAtX, float lookAtY, float lookAtZ, float Near, float Far){
	Camera(posX, posY, posZ, lookAtX, lookAtY, lookAtZ);
	near = near;
	far = far;
}

PerspectiveCamera::PerspectiveCamera(Point3D position, Vector3D lookAt, float Near, float Far) {
	Camera(position, lookAt);
	near = Near;
	far = Far;
}

PerspectiveCamera::PerspectiveCamera(Point3D position, Point3D lookAt, float Near, float Far) {
	Camera(position, lookAt);
	near = Near;
	far = Far;
}

PerspectiveCamera::~PerspectiveCamera(void)
{
}

void PerspectiveCamera::view() {
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
 
    gluPerspective(angle,getAspectRatio(),0.1,1500);
 
	glMatrixMode(GL_MODELVIEW);

	glLoadIdentity();

	gluLookAt(position.getX(), position.getY(), position.getZ(),
		lookAt.getX(), lookAt.getY(), lookAt.getZ(),
		up.getX(), up.getY(), up.getZ());
}